home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / ABox 1.9.5 / CPlus Files / ABPict.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-26  |  5.4 KB  |  247 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABPict.c
  15.  
  16. NAME
  17.     ABPict.c, part of the ABox project source code,
  18.     responsible for handling the AboutBox PICT class stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                ttempel@monmouth.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <ttempel@monmouth.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     9 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     28-july-94    -    ty    -    1.0.6--additions to support settable drag mgr usage
  38.                                     via the ABox Get/SetProperty methods
  39.     1-aug-94    -    ty    -    1.0.7--removed the LocalSendProc since it's not used here
  40.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  41.                             release and the associated Universal Headers from Apple:
  42.                             most methods that returned references now have "Ref" at
  43.                             the end of their methods names to prevent possible collisions
  44.                             with datatypes and classes of the same name (older versions
  45.                             of the compiler didn't have a problem with this).
  46.     25-oct-95    -    ty    -    changes for "const" usage under CW7; simplification of Boolean
  47.                             query methods
  48.  
  49. */
  50.  
  51. /*===========================================================================*/
  52.  
  53. /*======= Segmentation directives ========*/
  54.  
  55. #ifdef USE_MANUAL_SEGMENTATION
  56. #pragma segment ty
  57. #endif
  58.  
  59. /*============ Header files ==============*/
  60.     
  61. #include     "ABPict.h"
  62. #include    "ABox.h"
  63.  
  64. /*=============== Globals ================*/
  65.  
  66. /*================ CODE ==================*/
  67.  
  68.  
  69. /*=============================== ABPict::ABPict ================================*/
  70. ABPict::ABPict(void)
  71. {
  72.     mResType = kABPictResource;
  73. } // end ABPict
  74.  
  75.  
  76.  
  77. /*=============================== ABPict::~ABPict ================================*/
  78. ABPict::~ABPict(void)
  79. {
  80. } // end ~ABPict
  81.  
  82.  
  83.  
  84.  
  85. /*=============================== ABPict::Draw ================================*/
  86. OSErr    ABPict::Draw(WindowPtr window)
  87. {
  88.     OSErr        error = noErr;
  89.     Rect        box;
  90.     
  91.     //    begin here...
  92.     
  93.     error = ABObject::Draw(window);
  94.     if (error == noErr)
  95.     {
  96.         
  97.         //    get the display area...
  98.         //
  99.         box = this->ObjectRect();
  100.         
  101.         //    now get the picture information
  102.         
  103.         error = this->InitializeResource();
  104.         
  105.         if (!error) 
  106.         {
  107.             //    now do the drawing...
  108.             //
  109.             ::DrawPicture ((PicHandle)this->ResourceHandleRef(), &box);
  110.             error = ::QDError();
  111.         }    //    end if block
  112.     
  113.     }
  114.  
  115.     return error;
  116.     
  117. } // end Draw
  118.  
  119.  
  120.  
  121. /*=============================== ABPict::Event ================================*/
  122. Boolean    ABPict::Event(EventRecord *event)
  123. {
  124.     Boolean        handled = false;
  125.     Point        where;
  126.     OSErr        error = noErr;
  127.     Rect        box = this->ObjectRect();
  128.     
  129.     //    begin here...
  130.     //
  131.     if (!event)
  132.         return handled;
  133.     
  134.     switch (event->what) 
  135.     {
  136.         case    mouseDown:
  137.                 //    1.0.6 ty--check to see if we're allowed to use the DragMgr
  138.                 //
  139.                 ABox *theABox = (ABox *)GetWRefCon (this->OurWindowRef());
  140.                 Boolean    useDrag = false;
  141.                 
  142.                 if (theABox)
  143.                     error = theABox->GetProperty(kABoxUseDragMgr, &useDrag, NULL);
  144.                 
  145.                 where = event->where;
  146.                 ::GlobalToLocal(&where);
  147.                 if (::PtInRect (where, &box) && 
  148.                     (::FrontWindow() == this->OurWindowRef()) && 
  149.                     ABUEnvDragMgr::IsPresent() && 
  150.                     useDrag) 
  151.                 {
  152.                     //    DragMgr stuff here!!!
  153.                     
  154.                     if (::WaitMouseMoved(event->where)) 
  155.                     {
  156.                         //    the user is trying to Drag
  157.                         //    from the field to someplace
  158.                         this->DragMgrEventRef() = event;
  159.                         error = Begin();
  160.                         error = End();
  161.                     } // end if block
  162.                 } // end if block
  163.             break;
  164.         default:
  165.             break;
  166.     } // end switch block
  167.     
  168.     return handled;
  169. } // end Event
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176. /*=============================== ABPict::Initialize ================================*/
  177. OSErr    ABPict::Initialize(void)
  178. {
  179.     OSErr                error = noErr;
  180.     Ptr                    ptr = NULL;
  181.     Size                ptrSize = 0;
  182.     
  183.     //    OVERRIDE of the ABUEnvDragMgr method!
  184.     if (this->IsDragInitialized())
  185.         return noErr;
  186.     
  187.     this->DragRectRef() = this->ObjectRect();
  188.     error = ABUEnvDragMgr::Initialize();
  189.     if (error)
  190.         return error;
  191.  
  192.     error = ::SetDragSendProc (this->DragRef(),
  193.                             this->DragUPPRef(),
  194.                             this);
  195.     if (error)
  196.         return error;
  197.     
  198.     //    now create the Send information
  199.     ::HLock (this->ResourceHandleRef());
  200.     ptr = *(this->ResourceHandleRef());
  201.     ptrSize = ::GetHandleSize(this->ResourceHandleRef());
  202.     
  203.     error = ::AddDragItemFlavor(this->DragRef(),
  204.                                 this->ItemRef(),
  205.                                 kABPictResource,
  206.                                 ptr,
  207.                                 ptrSize,
  208.                                 kABdefaultFlavorFlags);
  209.     ::HUnlock (this->ResourceHandleRef());
  210.     
  211.     this->DragInitializedRef() = true;    
  212.     
  213.     return error;
  214.  
  215. }    // end Initialize
  216.  
  217.  
  218.  
  219.  
  220.  
  221. /*=============================== ABPict::Begin ================================*/
  222. OSErr    ABPict::Begin(void)
  223. {
  224.     OSErr    error;
  225.     
  226.     //    OVERRIDE of the ABUEnvDragMgr method! but be certain to call
  227.     //    the ABUEnvDragMgr method when finished here!!!!
  228.     
  229.     error = this->Initialize();
  230.     if (error)
  231.         return error;
  232.         
  233.     error = ABUEnvDragMgr::Begin();
  234.     
  235.     return error;
  236.  
  237. }    // end Begin
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245. //    end of file
  246.  
  247.